public class Test1117 {
    //删除有序数组中的重复项
    public int removeDuplicates(int[] nums) {
        int n = nums.length;
        if(n == 0){
            return 0;
        }
        int fast = 1,slow = 1;
        while(fast<n){
            if(nums[fast]!=nums[fast-1]){
                nums[slow] = nums[fast];
                ++slow;
            }
            ++fast;
        }
        return slow;
    }

    //约瑟夫问题
    public int iceBreakingGame(int num, int target) {
        return f(num, target);
    }

    public int f(int num, int target) {
        if (num == 1) {
            return 0;
        }
        int x = f(num - 1, target);
        return (target + x) % num;
    }
}
